#!/usr/bin/env python
# -*- coding:utf-8 -*-
import pika
#durable
########################## 消费者 #########################

connection = pika.BlockingConnection(pika.ConnectionParameters(host='192.168.136.8'))
channel = connection.channel()

# make message persistent
channel.queue_declare(queue='hello', durable=True)


def callback(ch, method, properties, body):
    print(" [x] Received %r" % body)
    import time
    time.sleep(10)
    print 'ok'
    ch.basic_ack(delivery_tag = method.delivery_tag)

channel.basic_consume(callback,
                      queue='hello',
                      no_ack=False)

print(' [*] Waiting for messages. To exit press CTRL+C')
channel.start_consuming()